/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package utiles;
import java.util.*;
import jxl.*;
import jxl.write.*;
import java.io.File;

/**
 *
 * @author Frank
 */
public class Utiles_ExportarExcel {

    public Utiles_ExportarExcel() {

    }

    public void escribirExcel( ArrayList dat, File file ){       
        WritableWorkbook workbook = null;
        try{
            workbook = Workbook.createWorkbook( file );
            WritableSheet sheet = workbook.createSheet("Hoja 1", 0);
            int nfila = dat.size();
            int ncol = ( ( ArrayList ) dat.get(0) ).size();
            for( int i = 0; i < nfila; i++ ){
                for( int j = 0; j < ncol; j++ ){
                    System.out.println( "fila: " + i + " columna: " + j );
                    Label label = new Label( j, i, ( ( ArrayList )dat.get(i) ).get(j).toString() );
                    sheet.addCell(label);
                }
            }
            workbook.write();
            workbook.close();
        }catch( Exception er ){
            er.printStackTrace();
            return;
        }
    }
}
